package com.controller.user;

import com.dto.FriendsCommentDto;
import com.dto.FriendsDto;
import com.dto.LoginDto;
import com.pojo.User;
import com.service.FriendsService;
import com.utils.PageResult;
import com.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/friends")
@Api(tags = "朋友圈相关接口")
public class FriendsController {
    @Autowired
    private FriendsService friendsService;


    /**
     * 发朋友圈
     * @param friendsDto
     * @return
     */
    @PostMapping("/submit")
    @ApiOperation("发朋友圈")
    public Result<String> submit(@RequestBody FriendsDto friendsDto) {
        friendsService.submit(friendsDto);
        return Result.success("发布成功");
    }

    /**
     * 分页查询
     * @param page
     * @param pageSize
     * @return
     */
    @GetMapping("/page")
    @ApiOperation("分页查询")
    public Result<PageResult> page(int page, int pageSize){
        PageResult pageResult=friendsService.pageQuery(page,pageSize);
        return Result.success(pageResult);
    }
    @GetMapping("/nice")
    @ApiOperation("朋友圈点赞")
    public Result<String> nice(Long friendId){
        friendsService.nice(friendId);
        return Result.success("点赞成功");
    }
    @PostMapping("/comment")
    @ApiOperation("朋友圈评论")
    public Result<String> comment(@RequestBody FriendsCommentDto friendsCommentDto) {
        friendsService.comment(friendsCommentDto);
        return Result.success("发布成功");
    }

}
